# Copyright (c) 2018 Presto Labs Pte. Ltd.
# Author: jaewon

from coin.exchange.okex_futures.ws.subscriber import OkexFuturesSubscriber
from coin.exchange.okex_futures_v3.ws.subscriber import OkexFuturesSubscriber \
    as OkexFuturesV3Subscriber
from coin.strategy.mm.feed_builder import (
    OkexFuturesFlowBookBuilder,
    OkexFuturesV3FlowBookBuilder,
    OkexFuturesV3RealtimeFlowBookBuilder,
)
from coin.strategy.mm.base.feed import BaseFeedSubsystem
from coin.strategy.mm.subscription import SubscriptionRequest


class OkexFuturesFeedSubsystem(BaseFeedSubsystem):
  FeedSubReq = SubscriptionRequest('Futures', 'Okex', 'v1')
  FeedSubscriber = OkexFuturesSubscriber
  FlowBookBuilder = OkexFuturesFlowBookBuilder

  def _get_subscription(self):
    return [product.native_subscription_symbol for product in self._products]

  def set_price_limit_error_callback(self, callback):
    self._price_limit_error_callback = callback


class OkexFuturesV3FeedSubsystem(BaseFeedSubsystem):
  FeedSubReq = SubscriptionRequest('Futures', 'Okex', 'v3')
  FeedSubscriber = OkexFuturesV3Subscriber
  FlowBookBuilder = OkexFuturesV3FlowBookBuilder

  def _get_subscription(self):
    return [product.native_subscription_symbol for product in self._products]

  def set_price_limit_error_callback(self, callback):
    self._price_limit_error_callback = callback


class OkexFuturesV3RealtimeFeedSubsystem(BaseFeedSubsystem):
  FeedSubReq = SubscriptionRequest('Futures', 'Okex', 'v3_realtime')
  FeedSubscriber = OkexFuturesV3Subscriber
  FlowBookBuilder = OkexFuturesV3RealtimeFlowBookBuilder

  def _get_subscription(self):
    return [product.native_subscription_symbol for product in self._products]

  def set_price_limit_error_callback(self, callback):
    self._price_limit_error_callback = callback
